﻿using Sidvall.AuthorizationManager.UI.ViewModels;
using Sidvall.UI.Views;
using System.Windows;

namespace Sidvall.AuthorizationManager.UI.Wpf
{
	public partial class MainWindow : Window
	{
		#region Public Members

		public MainWindowViewModel ViewModel
		{
			get
			{
				return (MainWindowViewModel)this.DataContext;
			}
			set
			{
				this.DataContext = value;
			}
		}

		#endregion
		#region Events

		private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			var viewEventArgs = await Sidvall.UI.SystemContext.Current.ConfigurationContext.Regions.NotifyContainerViewsAsync(ViewEventType.ApplicationClosing, Sidvall.UI.Wpf.SystemContext.Current.MainWindow);
			if (viewEventArgs.Cancel)
			{
				e.Cancel = true;
			}
		}

		#endregion
		#region Constructors

		public MainWindow()
		{
			InitializeComponent();

			this.Style = (Style)FindResource(typeof(Window));
			this.Width = 1174;
			this.Height = 800;
			this.Language = System.Windows.Markup.XmlLanguage.GetLanguage(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
			this.ViewModel = new MainWindowViewModel();
		}

		#endregion
	}
}
